package controllers

import (
	"io/ioutil"

	"github.com/astaxie/beego"
)

type MainController struct {
	beego.Controller
}

func (c *MainController) Get() {
	content, err := ioutil.ReadFile("views/index.html")
	if err != nil {
		c.Ctx.WriteString(err.Error())
		return
	}
	c.Ctx.WriteString(string(content))
}

func (c *MainController) GetData() {
	fileContent, err := ioutil.ReadFile("conf/template.json")
	if err != nil {
		c.Ctx.Output.Body([]byte(err.Error()))
		return
	}
	c.Data["test"] = "test"
	c.Ctx.Output.Body(fileContent)
}
